package com.geo.smallcredit.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.geo.smallcredit.R;
import com.geo.smallcredit.vo.MessageBean;

public class MyMessageAdapter  extends BaseAdapter{
	private Context context;
	private Helper h;
	private List<MessageBean> list;
	
	public MyMessageAdapter(Context context, List<MessageBean> list) {
		super();
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) {
		if (view == null) {
			view = LayoutInflater.from(context).inflate(
					R.layout.my_main_message_item, null);
			h = new Helper();
			h.gonggao = (ImageView) view
					.findViewById(R.id.my_main_message_item_gonggao);
			h.tongzhi = (TextView) view
					.findViewById(R.id.my_main_message_item_text);
			h.data = (TextView) view
					.findViewById(R.id.my_main_message_item_data);
			h.time = (TextView) view
					.findViewById(R.id.my_main_message_item_time);
			h.state = (TextView) view
					.findViewById(R.id.my_main_message_item_state);
			h.dian = (ImageView) view
					.findViewById(R.id.my_main_message_item_dian);
			h.front = (ImageView) view
					.findViewById(R.id.my_main_message_item_front);
			view.setTag(h);
		}
		h = (Helper) view.getTag();
		h.gonggao.setBackgroundResource(list.get(position).getImg());
		h.tongzhi.setText(list.get(position).getTongzhi());
		h.data.setText(list.get(position).getData());
		h.time.setText(list.get(position).getTime());
		h.state.setText(list.get(position).getState());
		h.dian.setBackgroundResource(list.get(position).getDian());
		h.front.setBackgroundResource(list.get(position).getFront());
		return view;
	}

	class Helper {
		ImageView gonggao, dian, front;
		TextView tongzhi, data, time, state;
	}
}
